<template>
  <div class="dashboard-editor-container">
    <el-row :gutter="32">
      <el-col :xs="24" :sm="24" :lg="14">
        <div style="float:right">
          <el-date-picker
            v-model="filters.year"
            type="year"
            placeholder="选择年"
            style="width:120px"
            value-format="yyyy"
          />
          <el-select v-model="filters.month" placeholder="请选择" style="width:120px">
            <el-option label="全年" :value="0" />
            <el-option label="1月" :value="1" />
            <el-option label="2月" :value="2" />
            <el-option label="3月" :value="3" />
            <el-option label="4月" :value="4" />
            <el-option label="5月" :value="5" />
            <el-option label="6月" :value="6" />
            <el-option label="7月" :value="7" />
            <el-option label="8月" :value="8" />
            <el-option label="9月" :value="9" />
            <el-option label="10月" :value="10" />
            <el-option label="11月" :value="11" />
            <el-option label="12月" :value="12" />
            <el-option label="一季度" :value="13" />
            <el-option label="二季度" :value="14" />
            <el-option label="三季度" :value="15" />
            <el-option label="四季度" :value="16" />
          </el-select>
        </div>
        <h3 style="margin:0 0 30px">数据统计<span style="font-weight:lighter">（所有案件均处于规定处置时间内）</span></h3>
        <panel-group @handleSetLineChartData="handleSetLineChartData" />

        <h3 style="margin-top:0">{{ lineChartTitle }}</h3>
        <el-row style="background:#fff;padding:16px 16px 0;margin-bottom:32px;">
          <line-chart :chart-data="lineChartData" />
        </el-row>

        <el-row :gutter="32">
          <el-col :xs="24" :sm="24" :lg="12">
            <div class="chart-wrapper">
              <h3>全年各阶段案件数统计</h3>
              <pie-chart />
            </div>
          </el-col>
          <el-col :xs="24" :sm="24" :lg="12">
            <div class="chart-wrapper">
              <h3>当前各阶段案件数统计</h3>
              <bar-chart />
            </div>
          </el-col>
        </el-row>

      </el-col>
      <el-col :xs="24" :sm="24" :lg="10">

        <el-row :gutter="8">

          <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 24}" :xl="{span: 24}" style="padding-right:8px;margin-bottom:30px;">
            <h3 style="margin:0 0 30px">新闻中心</h3>
            <news-table />
          </el-col>
          <el-col :xs="{span: 24}" :sm="{span: 24}" :md="{span: 24}" :lg="{span: 24}" :xl="{span: 24}" style="padding-right:8px;margin-bottom:30px;">
            <h3 style="margin-top:0">消息提醒</h3>
            <transaction-table />
          </el-col>
        </el-row>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import PanelGroup from './admin/components/PanelGroup'
import LineChart from './admin/components/LineChart'
// import RaddarChart from './admin/components/RaddarChart'
import PieChart from './admin/components/PieChart'
import BarChart from './admin/components/BarChart'
import TransactionTable from './admin/components/TransactionTable'
import NewsTable from './admin/components/NewsTable'
// import TodoList from './admin/components/TodoList'
// import BoxCard from './admin/components/BoxCard'

const lineChartData = {
  messages: {
    expectedData: [1, 1, 0, 2, 1, 1],
    actualData: [2, 2, 2, 1, 2, 3, 2, 2, 1, 2, 3, 0]
  },
  newVisitis: {
    expectedData: [200, 192, 120, 144, 160, 130],
    actualData: [180, 160, 151, 106, 145, 150, 130, 160, 151, 106, 145, 150]
  },
  purchases: {
    expectedData: [80, 100, 121, 104, 105, 90],
    actualData: [120, 90, 100, 138, 142, 130, 130, 100, 138, 142, 130, 130]
  }
  // shoppings: {
  //   expectedData: [130, 140, 141, 142, 145, 150, 160],
  //   actualData: [120, 82, 91, 154, 162, 140, 130]
  // }
}

export default {
  name: 'DashboardAdmin',
  components: {
    PanelGroup,
    LineChart,
    // RaddarChart,
    PieChart,
    BarChart,
    TransactionTable,
    NewsTable
    // TodoList,
    // BoxCard
  },
  data() {
    return {
      lineChartData: lineChartData.messages,
      filters: {
        year: '2021',
        month: 0
      },
      lineChartTitle: '案件数同期对比'
    }
  },
  methods: {
    handleSetLineChartData(type) {
      switch (type) {
        case 'messages':
          this.lineChartTitle = '案件数同期对比'
          break
        case 'newVisitis':
          this.lineChartTitle = '集资人数同期对比'
          break
        case 'purchases':
          this.lineChartTitle = '涉及金额（万元）同期对比'
          break
      }
      this.lineChartData = lineChartData[type]
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
</style>
